package com.soft.javase.ch10.test.function;

import java.util.function.BiFunction;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/5/7
 *
 * BiFunction<T, U, R>练习
 * 将String类型的姓名、Integer类型的年龄，转换成Person对象
 */
public class PersonCreator {
    public static void main(String[] args) {
        // 使用BiFunction实现姓名和年龄到Person的转换
        BiFunction<String, Integer, Person> createPerson = (name, age) -> new Person(name, age);

        BiFunction<String, Integer, Person> createPersonMethodRef = Person::new;

        Person person1 = createPerson.apply("张三", 30);
        Person person2 = createPersonMethodRef.apply("李四", 25);

        System.out.println(person1);
        System.out.println(person2);
    }
}
